home *** CD-ROM | disk | FTP | other *** search
- {$APPTYPE CONSOLE}
- {$DEFINE DRBOB}
- {$R BITMAP.RES}
- {$I-}
- uses
- Windows, SysUtils, Classes, Graphics, JPEG {$IFDEF DRBOB}, DrBobDOS{$ENDIF};
- type
- Digits = 0..9;
- var
- Digit: Array[Digits] of TBitmap;
- Bitmap: TBitmap;
- FromRect,ToRect: TRect;
- Stream: TMemoryStream;
- counter,i: Integer;
- log: Text;
- t: Char;
-
- function Number(i: Digits): TBitmap;
- begin
- if Digit[i] = nil then
- begin
- Digit[i] := TBitmap.Create;
- Digit[i].LoadFromResourceID(HInstance, i) { 0 = 10 }
- end;
- Result := Digit[i]
- end {Number};
-
- begin
- if ParamCount = 0 then { for use in web browsers }
- begin
- writeln('content-type: image/jpg');
- writeln
- end;
- Digit[0] := TBitmap.Create;
- Digit[0].LoadFromResourceID(HInstance, 10);
- Bitmap := TBitmap.Create;
- try
- Bitmap.LoadFromResourceID(HInstance, 42);
- ToRect.Left := 2;
- ToRect.Top := 2;
- ToRect.Right := 20;
- ToRect.Bottom := 25;
- FromRect.Left := 1;
- FromRect.Top := 1;
- FromRect.Right := 20;
- FromRect.Bottom := 25;
- { COUNTER }
- System.Assign(log,'counter');
- reset(log);
- if IOResult = 0 then readln(log,counter)
- else counter := 0;
- Inc(counter);
- rewrite(log);
- writeln(log,counter);
- close(log);
- if IOResult <> 0 then { skip };
- {$IFDEF DRBOB}
- { LOG }
- ShortDateFormat := 'YYYYMMDD';
- System.Assign(log,DateToStr(Now) + '.log');
- ShortDateFormat := 'YYYY/MM/DD';
- ShortTimeFormat := 'HH:MM:SS';
- reset(log);
- if IOResult = 0 then Append(log)
- else Rewrite(log);
- write(log,counter:7,': ',DateTimeToStr(Now),' ');
- with TBDosEnvironment.Create(nil) do
- try
- write(log,GetDosEnvStr('REMOTE_ADDR'));
- finally
- Free
- end;
- writeln(log);
- close(log);
- if IOResult <> 0 then { skip };
- {$ENDIF}
-
- Bitmap.Canvas.CopyMode := cmSrcPaint;
- Bitmap.Canvas.CopyRect(ToRect,Number((counter div 1000000) mod 10).Canvas,FromRect);
- Inc(ToRect.Left,21);
- Inc(ToRect.Right,21);
- Bitmap.Canvas.CopyRect(ToRect,Number((counter div 100000) mod 10).Canvas,FromRect);
- Inc(ToRect.Left,20);
- Inc(ToRect.Right,20);
- Bitmap.Canvas.CopyRect(ToRect,Number((counter div 10000) mod 10).Canvas,FromRect);
- Inc(ToRect.Left,20);
- Inc(ToRect.Right,20);
- Bitmap.Canvas.CopyRect(ToRect,Number((counter div 1000) mod 10).Canvas,FromRect);
- Inc(ToRect.Left,21);
- Inc(ToRect.Right,21);
- Bitmap.Canvas.CopyRect(ToRect,Number((counter div 100) mod 10).Canvas,FromRect);
- Inc(ToRect.Left,20);
- Inc(ToRect.Right,20);
- Bitmap.Canvas.CopyRect(ToRect,Number((counter div 10) mod 10).Canvas,FromRect);
- Inc(ToRect.Left,20);
- Inc(ToRect.Right,20);
- Bitmap.Canvas.CopyRect(ToRect,Number(counter mod 10).Canvas,FromRect);
- with TJPEGImage.Create do
- try
- Assign(Bitmap);
- CompressionQuality := 75; { reduces jpeg image size by factor of 3 }
- Stream := TMemoryStream.Create;
- try
- SaveToStream(Stream);
- Stream.Seek(0,0);
- for i:=1 to Stream.Size do
- begin
- Stream.Read(t,1);
- write(t)
- end
- finally
- Stream.Free
- end
- finally
- Free
- end
- finally
- for i:=0 to 9 do
- begin
- if Assigned(Digit[i]) then Digit[i].Free;
- Digit[i] := nil
- end;
- Bitmap.Free
- end
- end.
-